package com.atguigu.ssyx.search.controller;

import com.atguigu.ssyx.common.result.Result;
import com.atguigu.ssyx.search.service.SkuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 杨林
 * @create 2023-08-02 10:29 星期三
 * description:
 */
@Api(tags = "收索模块商品信息管理")
@RestController
@RequestMapping("/api/sku")
public class SkuApiController {
    
    @Autowired
    private SkuService skuService;
    
    /**
     *  商品上架：将商品信息放入到ES中 
     * @param skuId
     * @return
     */
    @ApiOperation(value = "商品上架")
    @GetMapping("/inner/upperSku/{skuId}")
    public Result upperGoods(@PathVariable("skuId") Long skuId){
        skuService.upperGoods(skuId);
        return Result.ok();    
    }


    /**
     * 商品下架：删除ES中的商品信息
     * @param skuId
     * @return
     */
    @ApiOperation(value = "商品下架")
    @GetMapping("/inner/lowerSku/{skuId}")
    public Result lowerGoods(@PathVariable("skuId") Long skuId){
        skuService.lowerGoods(skuId);
        return Result.ok();
    }
}
